package com.cqeec.springbootdemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestControllar {
    @RequestMapping("/abc")
    @ResponseBody
//自动将方法返回值写入http的响应中，获取json，构建restful中的api
    public String abc(@RequestParam(name = "name",
            defaultValue = "unKnow")String name,
    @RequestParam(name = "pwd",
    defaultValue = "unKnow")String pwd){
        return "hell spring boot"+" username="+name+"pwd"+pwd;
    }
//    restful获取参数
    @RequestMapping("/test/{name}")
    @ResponseBody
    public String test(@PathVariable("name")String name){
        return name;
    }
//    页面跳转
    @RequestMapping("/toPage")
    public String toPage(){
        return "aaa/index.html";
    }
}
